<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>
<body>
    <input type="text">
    <button id="btn"> click here</button>
    <script>
        function testInput(inputValue){
            // 匹配正数
            let pattern1=/^([0-9]{1,})$/
            // 匹配小数
            let pattern2=/^([0-9]{1,}[.][0-9]*)$/
            if(pattern1.test(inputValue)||pattern2.test(inputValue)){
                return true
            }
            return false
        }
        console.log(testInput('123'));
        console.log(testInput(123.123));
        console.log(testInput("123.123-"));
        console.log(testInput("!"));
    </script>
</body>
</html>